<?php
/**
 * Abstract model for SQL SELECT query
 */
abstract class SQLSelect {
    protected $strTableName;
	protected $objAlias;
	protected $objOptions;
	protected $objColumns;
	protected $objJoins;
	protected $objConditions;
	protected $objGroupBy;
	protected $objHaving;
	protected $objOrderBy;
	protected $objLimit;

	/**
	 * Sets table name directly from constructor.
	 *
	 * @param string $strTableName
	 */
	public function __construct($strTableName) {
		$this->strTableName = $strTableName;
	}
	
	/**
	 * Sets options for query.
	 * 
	 * @param SQLOptionsClause $objSQLOptions
	 * @return SQLSelect
	 */
	public function setOptions($objSQLOptions) {
		$this->objOptions = $objSQLOptions;
		return $this;
	}

	/**
	 * Sets an alias for current table to be used in join queries.
	 *
	 * @param string $strAlias
	 * @return MySQLDelete
	 */
	public function setAlias($strAlias) {
		$this->objAlias = new SQLAliasClause($this->strTableName, $strAlias);
		return $this;
	}
	
	/**
	 * Sets columns for query.
	 * 
	 * @param SQLColumnsClause $objSQLColumns
	 * @return SQLSelect
	 */
	public function setColumns($objSQLColumns) {
		$this->objColumns = $objSQLColumns;
		return $this;
	}
	
	/**
	 * Sets JOIN clauses for query.
	 * 
	 * @param SQLJoinsClause $objSQLJoins
	 * @return SQLSelect
	 */
	public function setJoins($objSQLJoins) {
		$this->objJoins = $objSQLJoins;
		return $this;
	}
	
	/**
	 * Sets WHERE clause for query.
	 * 
	 * @param SQLConditionsClause $objConditions
	 * @return SQLSelect
	 */
	public function setConditions($objConditions) {
		$this->objConditions = $objConditions;
		return $this;
	}
	
	/**
	 * Sets GROUP BY clause for query.
	 * 
	 * @param SQLGroupByClause $objGroupBy
	 * @return SQLSelect
	 */
	public function setGroupBy($objGroupBy) {
		$this->objGroupBy = $objGroupBy;
		return $this;
	}
	
	/**
	 * Sets HAVING clause for query.
	 * 
	 * @param SQLHavingClause $objHaving
	 * @return SQLSelect
	 */
	public function setHaving($objHaving) {
		$this->objHaving = $objHaving;
		return $this;
	}
	
	/**
	 * Sets ORDER BY clause for query.
	 * 
	 * @param SQLOrderByClause $objOrderBy
	 * @return SQLSelect
	 */
	public function setOrderBy($objOrderBy) {
		$this->objOrderBy = $objOrderBy;
		return $this;
	}
	
	/**
	 * Sets LIMIT clause for query.
	 * 
	 * @param SQLLimitClause $objLimit
	 * @return SQLSelect
	 */
	public function setLimit($objLimit) {
		$this->objLimit = $objLimit;
		return $this;
	}
	
	abstract public function toString();
}